<template>
  <nav>
    <div class="banxin tanxin nav_box">
      <img src="@/assets/images/indexLogo.png" alt="" />
      <ul class="tanxin">
        <router-link
          to="/"
          tag="li"
          :class="{ active: $route.path == '/' || $route.path == '/home' }"
          >首页</router-link
        >
        <router-link
          :class="{ active: $route.path == '/all' }"
          to="/all"
          tag="li"
          >全部商品</router-link
        >
        <router-link
          :class="{ active: $route.path == '/ures' }"
          to="/ures"
          tag="li"
          >个人中心</router-link
        >
        <router-link
          :class="{ active: $route.path == '/order' }"
          to="/order"
          tag="li"
          >我的订单</router-link
        >
        <router-link
          :class="{ active: $route.path == '/free' }"
          to="/free"
          tag="li"
          >专属福利</router-link
        >
      </ul>
      <div class="search tanxin">
        <input
          type="text"
          placeholder="搜索全部商品直接回车"
          v-model="searchValue"
          @keyup.enter="chuanFn"
        />
        <div class="btn" @click="chuanFn">
          <img src="@/assets/images/search.png" alt="" />
        </div>
      </div>
    </div>
  </nav>
</template>

<script>
export default {
  data() {
    return {
      // 输入框的数据
      searchValue: null,
    };
  },
  methods: {
    chuanFn() {
      this.$router.push(`/all?keyword=${this.searchValue}`);
    },
  },
};
</script>
 
<style lang = "less" scoped>
@import "@/assets/base.less";
nav {
  /* background: @black; */
  background: #fff;
  .nav_box {
    height: 99px;
    align-items: center;
    ul {
      width: 500px;
      li {
        font-size: 16px;
        color: @black;
        cursor: pointer;
        &.active {
          color: @blue;
          font-weight: bold;
        }
      }
    }
    .search {
      width: 214px;
      height: 40px;
      border: 1px solid #dedede;
      border-radius: 20px;
      overflow: hidden;
      input {
        width: 264px;
        text-indent: 1em;
        border: 1px solid #dedede;
        box-sizing: border-box;
        outline: none;
      }
      .btn {
        width: 50px;
        background: @blue;
        display: flex;
        justify-content: center;
        align-items: center;
        cursor: pointer;
      }
    }
  }
}
</style>